package cn.xxm.dongbao.user.service.impl;

import cn.xxm.dongbao.user.config.db.TargetDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.xxm.dongbao.user.common.PageUtils;
import cn.xxm.dongbao.user.common.Query;

import cn.xxm.dongbao.user.dao.UmsMemberDao;
import cn.xxm.dongbao.user.entity.UmsMemberEntity;
import cn.xxm.dongbao.user.service.UmsMemberService;


@Service("umsMemberService")
public class UmsMemberServiceImpl extends ServiceImpl<UmsMemberDao, UmsMemberEntity> implements UmsMemberService {

    @Autowired
    private UmsMemberDao umsMemberDao;

    @Override
    @TargetDataSource(value = "slaveDataSource")
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<UmsMemberEntity> page = this.page(
                new Query<UmsMemberEntity>().getPage(params),
                new QueryWrapper<UmsMemberEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    @TargetDataSource(value = "masterDataSource")
    public void updateBySelectId(UmsMemberEntity umsMember) {
        UmsMemberEntity umsMemberEntity = umsMemberDao.selectById(umsMember.getId());
        umsMemberDao.updateById(umsMember);
    }

}
